package inherit;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-05-18
 * Time: 14:56
 */
class Base{
    int a;
    int b;
    public void methodA(int a){
        System.out.println("Base中的methodA()");
    }
}

public class Derived extends Base{
    int a;
    int c;

    public void methodA(){
        System.out.println("Derived::methodA()");
    }

    public void methodB(){
        System.out.println("Derived中的methodB()方法");
    }

    public void methodC(){
        methodB();//访问子类自己的methodB()
        methodA(10);//访问父类继承的methodA()
        //methodD();//编译失败 在整个继承体系中没有发现方法methodD()
    }
    public void method(){
        super.a = 10;//当父类和子类都拥有同名的变量时 优先访问子类自己
        b = 20;
        c = 30;
        //d = 100;
        //System.out.println(super.a);
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
    }

    public static void main(String[] args) {
        Derived derived = new Derived();
        derived.method();

        /*Base base = new Base();
        System.out.println(base.a);*/
    }
}
